<?php

class ZFKiller_Form_Element_Float extends ZFKiller_Form_Element_Text {

	public function __construct($spec, $options = null) {
		ZFKiller_Form_Element::formatDefaultOptions($spec, $options);

		parent::__construct($spec, $options);

		$this
				->addValidator(new Zend_Validate_Float())
		;

		ZFKiller_Form_Element::formatElementAsText($this);
	}
	
	public function getValue() {
		switch (ZFKiller_Form::getValueType()) {
			case ZFKiller_Form::GET_VALUE_TYPE_DB:
				return $this->getValueDb();
				break;
			case ZFKiller_Form::GET_VALUE_TYPE_USER:
				return $this->getValueUser();
				break;
			default:
				return $this->getValueUser();
				break;
		}
	}

	public function getValueDb() {
		$value = parent::getValue();
		
		$filter = new Zend_Filter_LocalizedToNormalized();
		return $filter->filter($value);
	}

	public function getValueUser() {
		$value = parent::getValue();
		
		$filter = new Zend_Filter_NormalizedToLocalized();
		return $filter->filter($value);
	}

}